A computer system may execute one or more virtual machines. A virtual machine is a self-contained software environment that behaves as if it were a separate computer. Each virtual machine may execute its own operating system, typically referred to as a guest operating system. The first operating system loaded by a computer system, which executes on the native hardware of the computer system, is referred to as a host operating system.
Guest operating systems may measure the passage of time using several different approaches, such as tick counting and tickless timekeeping. In tick counting, the guest operating system instructs the computer system to periodically interrupt the guest operating system at a known rate, such as 100 times per second. The guest operating system handles such interrupts, called ticks, and maintains a count of those ticks to ascertain how much time has passed.
According to tickless timekeeping, the computer system maintains a count of the number of time units that have passed since the computer system booted, and the guest operating system simply reads the counter and computes how much time has passed when necessary. Tickless timekeeping has several advantages. In particular, it does not burden the CPU with interrupt handling and can measure time at a finer granularity. However, tickless timekeeping is practical only on computer systems that possesses a suitable hardware counter. The counter must run at a constant rate, be reasonably fast to read, and not often overflow.
Operating systems also keep mark the passage of absolute time or “wall-clock time.” To do so, when an operating system initially boots, the operating system may read wall-clock maintained by the hardware. The hardware may comprise a battery to power the wall-clock when the hardware is not powered on. Alternately, the wall-clock time may be obtained by the operating system from a server located over a network. To correct for long-term drift and other errors in time measurement, the operating system might periodically check its wall-clock against a network time server and make adjustments as needed.